Skip to content

Allow to estimate document count. #3951

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed

Allow to estimate document count. #3951

wants to merge 3 commits into from

Conversation

christophstrobl
Copy link
Member

Introduce an option that allows users to opt in on using estimatedDocumentCount instead of countDocuments in case the used filter query is empty.

Copy link
Member

@mp911de mp911de left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did a first review pass and left a few comments up for discussion. The comments apply also to the reactive bits.

* @param entityClass class that determines the collection to use. Must not be {@literal null}.
* @return the count of matching documents.
*/
Mono<Long> count(Query query, Class<?> entityClass);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: We should probably slim down the second documentation paragraph and link to both count methods via @see.

This commit introduce an option that allows users to opt in on using estimatedDocumentCount instead of countDocuments in case the used filter query is empty.
To still be able to retrieve the precise number of matching documents we also introduced MongoTemplate#preciseCount.
mp911de pushed a commit that referenced this pull request Mar 11, 2022
This commit introduce an option that allows users to opt in on using estimatedDocumentCount instead of countDocuments in case the used filter query is empty.
To still be able to retrieve the exact number of matching documents we also introduced MongoTemplate#exactCount.

Closes: #3522
Original pull request: #3951.
mp911de added a commit that referenced this pull request Mar 11, 2022
Reorder methods. Add links to Javadoc. Tweak wording.

See: #3522
Original pull request: #3951.
mp911de pushed a commit that referenced this pull request Mar 11, 2022
This commit introduce an option that allows users to opt in on using estimatedDocumentCount instead of countDocuments in case the used filter query is empty.
To still be able to retrieve the exact number of matching documents we also introduced MongoTemplate#exactCount.

Closes: #3522
Original pull request: #3951.
mp911de added a commit that referenced this pull request Mar 11, 2022
Reorder methods. Add links to Javadoc. Tweak wording.

See: #3522
Original pull request: #3951.
@mp911de mp911de added the type: enhancement A general enhancement label Mar 11, 2022
@mp911de mp911de added this to the 3.4 M4 (2021.2.0) milestone Mar 11, 2022
@mp911de mp911de closed this Mar 11, 2022
@mp911de mp911de deleted the issue/3522 branch March 11, 2022 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MongoCollection#countDocuments Performance in Driver 4.x [DATAMONGO-2669]
2 participants